#%RAML 0.8
---
title: SLL Service Catalogue Product Service
version: 1.0
baseUri: http://localhost:8080/product
documentation:
  - title: General API information
    content: TODO! Description of the Product Service Functions
protocols: [HTTP,HTTPS]

schemas:
    - iiType: !include schema/iiType.json
    - uuidType: !include schema/uuidType.json
    - cvType: !include schema/cvType.json
    - cvTypeList: !include schema/cvTypeList.json
    - productCreate: !include schema/productCreate.json
    - product: !include schema/product.json
    - productList: !include schema/productList.json
    - codeCreate: !include schema/codeCreate.json
    - codeDelete: !include schema/codeDelete.json
    - codeResponse: !include schema/codeResponse.json
    - codeList: !include schema/codeList.json
    - codeSystemCode: !include schema/codeSystemCode.json
    - codeSystem: !include schema/codeSystem.json
    - codeSystemList: !include schema/codeSystemList.json
    - codeSystemCreate: !include schema/codeSystemCreate.json
    - codeSystemDelete: !include schema/codeSystemDelete.json

/products:
  description: Service for creating, updating, reading products.
  displayName: ProductService
  get:
    description: List all stored Products
    responses:
      200:
        description: The requested Product information was found and is returned in the body.
        body:
          application/json:
            schema: productList
            example : |
              [
                {
                  "status" : "ACTIVE",
                  "name" : "Product Name",
                  "displayName" : "Product Displayname",
                  "description : "Product Description",
                  "creationTime": 1425410281000,
                  "updateTime": 1425410281000,
                  "updatedByHsaid" : "SE2321000016-1HF3",
                  "codes": [
                    {
                      "oid" : "1.2.4.5",
                      "code" : "157H",
                      "description" : "Code description",
                      "displayName" : "Code displayname",
                      "codeSystem" : "Name of the Code System indicated by the OID"
                    }
                  ]
                }
              ]
  post:
    description: Create a new product
    body:
      application/json:
        schema: productCreate
        example : |
          {
            "name" : "Product Name",
            "description : "Product Description",
            "status" : "ACTIVE",
            "updatedByHsaid" : "SE2321000016-1HF3",
            "displayName" : "Product Displayname"
          }
    responses:
      201:
        description: Creation successful.
        body:
          application/json:
            schema: product
            example: |
              {
                "status" : "ACTIVE",
                "name" : "Product Name",
                "displayName" : "Product Displayname",
                "description : "Product Description",
                "creationTime": 1425410281000,
                "updateTime": 1425410281000,
                "updatedByHsaid" : "SE2321000016-1HF3",
                "codes": [
                  {
                    "oid" : "1.2.4.5",
                    "code" : "157H",
                    "description" : "Code description",
                    "displayName" : "Code displayname",
                    "CodeSystem" : "Name of the Code System indicated by the OID"
                  }
                ]
              }
  put:
    description: Update a product
    body:
      application/json:
        schema: productCreate
        example : |
          {
            "name" : "Product Name",
            "description : "Product Description",
            "status" : "ACTIVE",
            "updatedByHsaid" : "SE2321000016-1HF3",
            "displayName" : "Product Displayname"
          }
    responses:
      200:
        description: Update successful.
        body:
          application/json:
            schema: product
            example: |
              {
                "status" : "ACTIVE",
                "name" : "Product Name",
                "displayName" : "Product Displayname",
                "description : "Product Description",
                "creationTime": 1425410281000,
                "updateTime": 1425410281000,
                "updatedByHsaid" : "SE2321000016-1HF3",
                "codes": [
                  {
                    "oid" : "1.2.4.5",
                    "code" : "157H",
                    "description" : "Code description",
                    "displayName" : "Code displayname",
                    "CodeSystem" : "Name of the Code System indicated by the OID"
                  }
                ]
              }
  /{productName}:
    description: Service for managing the product information for the product with a specific product name
    uriParameters:
       productName:
         displayName: The name of the Product to operate on.
         type: string
    get:
      description: Returns information about the product with the specified name
      responses:
        200:
          description: The requested Product was found and is returned in the body.
          body:
            application/json:
              schema: product
              example : |
                {
                  "status" : "ACTIVE",
                  "name" : "Product Name",
                  "displayName" : "Product Displayname",
                  "description : "Product Description",
                  "creationTime": 1425410281000,
                  "updateTime": 1425410281000,
                  "updatedByHsaid" : "SE2321000016-1HF3",
                  "codes": [
                    {
                      "oid" : "1.2.4.5",
                      "code" : "157H",
                      "description" : "Code description",
                      "displayName" : "Code displayname",
                      "CodeSystem" : "Name of the Code System indicated by the OID"
                    }
                  ]
                }
    delete:
      description: Delete the product with the specified product name
      responses:
        200:
          description: The deletion was successful
    /codes/:
      get:
        description: Fetches Code System Codes for the Product with the specified product name.
        responses:
          200:
            description: The requested Product was found and its Codes are returned in the body.
            body:
              application/json:
                schema: codeList
                example: |
                  [
                    {
                      "oid" : "1.2.4.5",
                      "code" : "157H",
                      "description" : "Code description",
                      "displayName" : "Code displayname",
                      "CodeSystem" : "Name of the Code System indicated by the OID"
                    }
                  ]
      put:
        description: Sets the entire collection of Code System Codes for the Product with the specified product name.
        body:
          application/json:
            schema: codeList
            example: |
              [
                {
                  "oid" : "1.2.4.5",
                  "code" : "157H",
                  "description" : "Code description",
                  "displayName" : "Code displayname",
                  "CodeSystem" : "Name of the Code System indicated by the OID"
                }
              ]
        responses:
          200:
            description: The Code list for the product was successfully replaced.
            body:
              application/json:
                schema: codeList
                example: |
                  [
                    {
                      "oid" : "1.2.4.5",
                      "code" : "157H",
                      "description" : "Code description",
                      "displayName" : "Code displayname",
                      "CodeSystem" : "Name of the Code System indicated by the OID"
                    }
                  ]

    /add/code:
      put:
        description: Adds the specified code system code to the specified product.
        body:
          application/json:
            schema: codeSystemCode
            example: |
              {
                "oid" : "1.2.4.5",
                "code" : "157H",
                "description" : "Code description",
                "displayName" : "Code displayname",
                "CodeSystem" : "Name of the Code System indicated by the OID"
              }
        responses:
          200:
            description: The code was added successfully

  /names:
    description: List all Products matching an incoming list of Product names.
    get:
      queryParameters:
          productName:
            description: A comma seperated list of product names to set. (RAML doesn't seem to have a way to set this, so it's just a string for now)
            type: string
      responses:
        200:
          description: The requested Product information was found and is returned in the body.
          body:
            application/json:
              schema: productList
              example : |
                [
                  {
                    "status" : "ACTIVE",
                    "name" : "Product Name",
                    "displayName" : "Product Displayname",
                    "description : "Product Description",
                    "creationTime": 1425410281000,
                    "updateTime": 1425410281000,
                    "updatedByHsaid" : "SE2321000016-1HF3",
                    "codes": [
                      {
                        "oid" : "1.2.4.5",
                        "code" : "157H",
                        "description" : "Code description",
                        "displayName" : "Code displayname",
                        "CodeSystem" : "Name of the Code System indicated by the OID"
                      }
                    ]
                  }
                ]
    /namebeginswith:
      description: List all Products whos name begins with the provided string.
      get:
        queryParameters:
            productName:
              description: A query string for product beginning with this String.
              type: string
        responses:
          200:
            description: The requested Product information was found and is returned in the body.
            body:
              application/json:
                schema: productList
                example : |
                  [
                    {
                      "status" : "ACTIVE",
                      "name" : "Product Name",
                      "displayName" : "Product Displayname",
                      "description : "Product Description",
                      "creationTime": 1425410281000,
                      "updateTime": 1425410281000,
                      "updatedByHsaid" : "SE2321000016-1HF3",
                      "codes": [
                        {
                          "oid" : "1.2.4.5",
                          "code" : "157H",
                          "description" : "Code description",
                          "displayName" : "Code displayname",
                          "CodeSystem" : "Name of the Code System indicated by the OID"
                        }
                      ]
                    }
                  ]
  /namecontains:
    description: List all Products whos name contains the provided string.
    get:
      queryParameters:
          productName:
            description: The query string.
            type: string
      responses:
        200:
          description: The requested Product information was found and is returned in the body.
          body:
            application/json:
              schema: productList
              example : |
                [
                  {
                    "status" : "ACTIVE",
                    "name" : "Product Name",
                    "displayName" : "Product Displayname",
                    "description : "Product Description",
                    "creationTime": 1425410281000,
                    "updateTime": 1425410281000,
                    "updatedByHsaid" : "SE2321000016-1HF3",
                    "codes": [
                      {
                        "oid" : "1.2.4.5",
                        "code" : "157H",
                        "description" : "Code description",
                        "displayName" : "Code displayname",
                        "codeSystem" : "Name of the Code System indicated by the OID"
                      }
                    ]
                  }
                ]
  /codes:
    description: List all Products whos code name matches the query parameter
    get:
      queryParameters:
          codeName:
            description: The query string.
            type: string
      responses:
        200:
          description: The requested Product information was found and is returned in the body.
          body:
            application/json:
              schema: productList
              example : |
                [
                  {
                    "status" : "ACTIVE",
                    "name" : "Product Name",
                    "displayName" : "Product Displayname",
                    "description : "Product Description",
                    "creationTime": 1425410281000,
                    "updateTime": 1425410281000,
                    "updatedByHsaid" : "SE2321000016-1HF3",
                    "codes": [
                      {
                        "oid" : "1.2.4.5",
                        "code" : "157H",
                        "description" : "Code description",
                        "displayName" : "Code displayname",
                        "codeSystem" : "Name of the Code System indicated by the OID"
                      }
                    ]
                  }
                ]
  /codesystems/{codeSystem}/codes/{codeName}:
    description: Service for managing the product information for the product with a specific product name
    uriParameters:
      codeSystem:
        displayName: The code system to list products for
        type: string
      codeName:
        displayName: The Code to list Products for.
        type: string
    get:
      description: Lists all Products matching the provided Code System and Name
      responses:
        200:
          description: The requested Product was found and is returned in the body.
          body:
            application/json:
              schema: productList
              example : |
                [
                  {
                    "status" : "ACTIVE",
                    "name" : "Product Name",
                    "displayName" : "Product Displayname",
                    "description : "Product Description",
                    "creationTime": 1425410281000,
                    "updateTime": 1425410281000,
                    "updatedByHsaid" : "SE2321000016-1HF3",
                    "codes": [
                      {
                        "oid" : "1.2.4.5",
                        "code" : "157H",
                        "description" : "Code description",
                        "displayName" : "Code displayname",
                        "codeSystem" : "Name of the Code System indicated by the OID"
                      }
                    ]
                  }
                ]

/codesystems:
  description: Service for creating, updating, reading code systems.
  displayName: CodeSystemService
  get:
    description: List all stored code systems
    responses:
      200:
        description: The requested code system information was found and is returned in the body.
        body:
          application/json:
            schema: codeSystemList
            example : |
              [
                {
                  "codes": [
                    {
                      "code": "1512",
                      "codeSystem": null,
                      "description": "Verksamhet d\u00e4r man erbjuder v\u00e5rd till personer som traumatiserats av krig och tortyr.",
                      "displayName": "Krigs- och tortyrskadev\u00e5rd",
                      "oid": "1.2.752.129.2.2.1.3"
                    },
                    {
                      "code": "1335",
                      "codeSystem": null,
                      "description": "Verksamhet d\u00e4r man handl\u00e4gger \u00f6gonsjukdomar.",
                      "displayName": "\u00d6gonsjukv\u00e5rd",
                      "oid": "1.2.752.129.2.2.1.3"
                    }
                  ],
                  "description": "Koder f\u00f6r v\u00e5rdtyper enligt SLL-EK",
                  "name": "SLL-EK v\u00e5rdtyper",
                  "oid": "1.2.752.97.3.1.11"
                }
              ]
  post:
    description: Create a new code system
    body:
      application/json:
        schema: codeSystemCreate
        example : |
          {
            "oid" : "6.2.9.364.123.7",
            "name : "Koder för klassificering av struturell papperstäthet i beganade kaffemuggar",
            "description" : "En beskrivning"
          }
    responses:
      201:
        description: Creation successful.
  put:
    description: Update a code system
    body:
      application/json:
        schema: codeSystemCreate
        example : |
          {
            "oid" : "6.2.9.364.123.7",
            "name : "Koder för klassificering av struturell papperstäthet i beganade kaffemuggar",
            "description" : "En beskrivning"
          }
    responses:
      200:
        description: Update successful.
  /{codeSystem}:
    description: Service for managing a specific code system
    uriParameters:
       codeSystem:
         displayName: The OID of the Code System to operate on.
         type: string
    get:
      description: Reads information about the code system with the specified OID
      responses:
        200:
          description: The requested code system was found and is returned in the body.
          body:
            application/json:
              schema: codeSystem
              example : |
                {
                  "codes": [
                    {
                      "code": "1512",
                      "codeSystem": null,
                      "description": "Verksamhet d\u00e4r man erbjuder v\u00e5rd till personer som traumatiserats av krig och tortyr.",
                      "displayName": "Krigs- och tortyrskadev\u00e5rd",
                      "oid": "1.2.752.129.2.2.1.3"
                    },
                    {
                      "code": "1335",
                      "codeSystem": null,
                      "description": "Verksamhet d\u00e4r man handl\u00e4gger \u00f6gonsjukdomar.",
                      "displayName": "\u00d6gonsjukv\u00e5rd",
                      "oid": "1.2.752.129.2.2.1.3"
                    }
                  ],
                  "description": "Koder f\u00f6r v\u00e5rdtyper enligt SLL-EK",
                  "name": "SLL-EK v\u00e5rdtyper",
                  "oid": "1.2.752.97.3.1.11"
                }
    delete:
      description: Delete the code system with the specified OID
      body:
        application/json:
          schema: codeSystemDelete
          example: |
            {
              "oid" : "1.5.2.6.8.3.3"
            }
      responses:
        200:
          description: The deletion was successful
    /codes:
      get:
        description: Fetches all the codes for the specified Code System OID.
        responses:
          200:
            description: The requested Code System was found and its Codes are returned in the body.
            body:
              application/json:
                schema: codeList
                example: |
                  [
                    {
                      "oid" : "1.2.4.5",
                      "code" : "157H",
                      "description" : "Code description",
                      "displayName" : "Code displayname",
                      "CodeSystem" : "Name of the Code System indicated by the OID"
                    }
                  ]
      post:
        description: Creates a new code entry in the specified Code System.
        body:
          application/json:
            schema: codeCreate
            example : |
              {
                "code": "1335",
                "description": "Verksamhet d\u00e4r man handl\u00e4gger \u00f6gonsjukdomar.",
                "displayName": "\u00d6gonsjukv\u00e5rd"
              }
        responses:
          201:
            description: Creation successful.
      put:
        description: Updates a code entry in the specified Code System.
        body:
          application/json:
            schema: codeCreate
            example : |
              {
                "code": "1335",
                "description": "Verksamhet d\u00e4r man handl\u00e4gger \u00f6gonsjukdomar.",
                "displayName": "\u00d6gonsjukv\u00e5rd"
              }
        responses:
          200:
            description: Update successful.
      delete:
        description: Delete a code with the specfied Code System.
        body:
          application/json:
            schema: codeDelete
            example: |
              {
                "code" : "1337"
              }
        responses:
          200:
            description: The deletion was successful
      /{name}:
        uriParameters:
          name:
            displayName: The code name to operate on
            type: string
        get:
          description: Find codes by codeSystem and codeName, codeName will be used with wildcards.
          responses:
            200:
              description:
              body:
                application/json:
                  schema: codeResponse
                  example: |
                    {
                      "code" : "157H",
                      "displayName" : "Code displayname",
                      "description" : "Code description",
                      "oid" : "1.2.4.5"
                    }

  /codes:
    get:
      description: Fetches all the codes for all the code systems.
      responses:
        200:
          description: The requested Codes are returned in the body.
          body:
            application/json:
              schema: codeList
              example: |
                [
                  {
                    "oid" : "1.2.4.5",
                    "code" : "157H",
                    "description" : "Code description",
                    "displayName" : "Code displayname",
                    "CodeSystem" : "Name of the Code System indicated by the OID"
                  }
                ]

    /{name}:
      uriParameters:
        name:
          displayName: The code name to operate on
          type: string
      get:
        description: Find codes by name, regardless of code system
        responses:
          200:
            description: The requested Codes are returned in the body.
            body:
              application/json:
                schema: codeList
                example: |
                  [
                    {
                      "oid" : "1.2.4.5",
                      "code" : "157H",
                      "description" : "Code description",
                      "displayName" : "Code displayname",
                      "CodeSystem" : "Name of the Code System indicated by the OID"
                    }
                  ]

    /displaynamecontains/{displayName}:
      uriParameters:
        displayName:
          displayName: The code name to operate on
          type: string
      get:
        description: List all Codes whos name contains the provided string, regardless of Code System.
        responses:
          200:
            description: The requested Code information was found and is returned in the body.
            body:
              application/json:
                schema: codeList
                example: |
                  [
                    {
                      "oid" : "1.2.4.5",
                      "code" : "157H",
                      "description" : "Code description",
                      "displayName" : "Code displayname",
                      "CodeSystem" : "Name of the Code System indicated by the OID"
                    }
                  ]

    /descriptioncontains/{description}:
      uriParameters:
        description:
          displayName: The code description to operate on
          type: string
      get:
        description: List all Codes whos description contains the provided string, regardless of Code System.
        responses:
          200:
            description: The requested Code information was found and is returned in the body.
            body:
              application/json:
                schema: codeList
                example: |
                  [
                    {
                      "oid" : "1.2.4.5",
                      "code" : "157H",
                      "description" : "Code description",
                      "displayName" : "Code displayname",
                      "CodeSystem" : "Name of the Code System indicated by the OID"
                    }
                  ]